//
//  PhotoBrowser.m
//  JJHW_coreData
//
//  Created by huazi on 16/4/20.
//  Copyright © 2016年 HFKJ_LZQ. All rights reserved.
//

#import "PhotoBrowser.h"
#import "MJPhoto.h"
#import "MJPhotoBrowser.h"
@implementation PhotoBrowser
+(void)showBigPicWithImageUrls:(NSMutableArray *)imageUrls  AndIndex:(NSInteger)index  AndFirstImageView:(UIImageView *)tagImageView {
    NSMutableArray *photos =[[NSMutableArray alloc] init];
    if ([imageUrls count]>0)
    {
        for (NSInteger i = 0; i < [imageUrls count]; i++) {
            // 替换为中等尺寸图片
            MJPhoto *photo = [[MJPhoto alloc] init];
            //photo.image = [UIImage imageNamed:[ImageArray objectAtIndex:i]];
            NSString * getImageStrUrl = [imageUrls objectAtIndex:i];
            photo.url = [NSURL URLWithString:getImageStrUrl];
//            HZBaseViewController *currentVC =[[HYCurrentVCmanager shareInstance] currentVC];
//            photo.srcImageView = (UIImageView *)[currentVC.view viewWithTag:tagImageView+i];
            photo.srcImageView = tagImageView;
            [photos addObject:photo];
        }
        
        // 2.显示相册
        MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
        //        browser.delegate =self;
        browser.currentPhotoIndex = index; // 弹出相册时显示的第一张图片是？
        browser.photos = photos; // 设置所有的图片
        [browser show];
    }

}
+(void)showBigPicWithModels:(NSArray *)models  AndIndex:(NSInteger)index  AndFirstImageView:(UIImageView *)tagImageView {
    NSMutableArray *photos =[[NSMutableArray alloc] init];
    if ([models count]>0)
    {
        for (NSInteger i = 0; i < [models count]; i++) {
            // 替换为中等尺寸图片
            MJPhoto *photo = [[MJPhoto alloc] init];
            //photo.image = [UIImage imageNamed:[ImageArray objectAtIndex:i]];
            NSString * getImageStrUrl = [[models objectAtIndex:i] objectForKey:@"url"];
            photo.url = [NSURL URLWithString:getImageStrUrl];
//            HZBaseViewController *currentVC =[[HZCurrentVCManager shareInstance] currentVC];
//            photo.srcImageView = (UIImageView *)[currentVC.view viewWithTag:tagImageView+i];
            photo.srcImageView = tagImageView;
            [photos addObject:photo];
        }
        
        // 2.显示相册
        MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
        //        browser.delegate =(id)[[HZCurrentVCManager shareInstance] currentVC];
        browser.currentPhotoIndex = index; // 弹出相册时显示的第一张图片是？
        browser.photos = photos; // 设置所有的图片
        [browser show];
    }

}
@end
